package cn.wolfcode.ssm.service.impl;

import cn.wolfcode.ssm.domain.SystemDictionary;
import cn.wolfcode.ssm.mapper.SystemDictionaryMapper;
import cn.wolfcode.ssm.qo.QueryObject;
import cn.wolfcode.ssm.service.ISystemDictionaryService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SystemDictionaryServiceImpl implements ISystemDictionaryService {

    @Autowired
    private SystemDictionaryMapper systemDictionaryMapper;
    @Override
    public void delete(Long id) {
        systemDictionaryMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void save(SystemDictionary systemDictionaryt) {
        systemDictionaryMapper.insert(systemDictionaryt);
    }

    @Override
    public SystemDictionary getOne(Long id) {
        return systemDictionaryMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<SystemDictionary> getAll() {
        return systemDictionaryMapper.selectAll();
    }

    @Override
    public void update(SystemDictionary systemDictionaryt) {
        systemDictionaryMapper.updateByPrimaryKey(systemDictionaryt);
    }


    @Override
    public PageInfo<SystemDictionary> selctForPageResult(QueryObject qo) {
        //使用分页插件,传入当前页,每页显示数量
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<SystemDictionary> systemDictionaryts = systemDictionaryMapper.selectForResult(qo);
        return new PageInfo(systemDictionaryts);
    }
}
